package com.ld.control.business.process.service.impl;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ld.control.business.equipment.service.EquipmentService;
import com.ld.control.business.equipment.vo.resp.EquipmentRespVo;
import com.ld.control.business.process.mapper.ProcessNodeParamTmpMapper;
import com.ld.control.business.process.mapper.ProcessNodeTmpMapper;
import com.ld.control.business.process.mapper.ProcessTmpExtMapper;
import com.ld.control.business.process.mapper.ProcessTmpMapper;
import com.ld.control.business.process.model.ProcessNodeParamTmpModel;
import com.ld.control.business.process.model.ProcessNodeTmpModel;
import com.ld.control.business.process.model.ProcessTmpExtModel;
import com.ld.control.business.process.model.ProcessTmpModel;
import com.ld.control.business.process.service.ProcessNodeTmpService;
import com.ld.control.business.process.service.ProcessTmpService;
import com.ld.control.business.process.vo.req.ProcessTmpReqVo;
import com.ld.control.business.process.vo.resp.ProcessTmpRespVo;
import com.ld.control.exception.BusinessException;
import com.ld.control.utils.JWTUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.ObjectUtils;

import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 任务流程模板 服务实现类
 * </p>
 *
 * @author wangfeng
 * @since 2024-04-24
 */
@Slf4j
@Service
public class ProcessTmpServiceImpl extends ServiceImpl<ProcessTmpMapper, ProcessTmpModel> implements ProcessTmpService {

    @Autowired
    private JWTUtils jwtUtils;

    @Autowired
    private ProcessTmpMapper processTmpMapper;

    @Autowired
    private ProcessTmpExtMapper processTmpExtMapper;

    @Autowired
    private ProcessNodeTmpMapper processNodeTmpMapper;

    @Autowired
    private ProcessNodeParamTmpMapper processNodeParamTmpMapper;

    @Autowired
    private ProcessNodeTmpService processNodeTmpService;

    @Autowired
    private EquipmentService equipmentService;

    @Override
    public IPage<ProcessTmpRespVo> getPageList(Long regionId, String name, Integer type, Integer current, Integer size) {
        IPage<ProcessTmpRespVo> iPage = new Page<>(current, size);
        return processTmpMapper.selectPageList(iPage, regionId, name, type);
    }

    @Override
    public List<ProcessTmpRespVo> getAllList(Long regionId, String name, Integer type) {
        IPage<ProcessTmpRespVo> iPage = new Page<>(1, 9999);
        IPage<ProcessTmpRespVo> processTmpRespVoIPage = processTmpMapper.selectPageList(iPage, regionId, name, type);
        return processTmpRespVoIPage.getRecords();
    }

    @Override
    public ProcessTmpRespVo getById(Long id) {
        ProcessTmpRespVo processTmpRespVo = new ProcessTmpRespVo();
        ProcessTmpModel processTmpModel = processTmpMapper.selectById(id);
        BeanUtils.copyProperties(processTmpModel, processTmpRespVo);
        QueryWrapper<ProcessTmpExtModel> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq(ProcessTmpExtModel.PROCESS_TMP_ID, processTmpModel.getId());
        ProcessTmpExtModel processTmpExtModel = processTmpExtMapper.selectOne(queryWrapper);
        if (!ObjectUtils.isEmpty(processTmpExtModel) && !ObjectUtils.isEmpty(processTmpExtModel.getAllNodeInfo())) {
            String allNodeInfo = coverProcessTmpExt(processTmpExtModel.getAllNodeInfo());
            processTmpRespVo.setAllNodeInfo(allNodeInfo);
        }
        return processTmpRespVo;
    }

    @Override
    @Transactional
    public void deleteById(Long id) {
        // 删除节点信息
        Map<String, Object> processNodeTmpMap = new HashMap<>();
        processNodeTmpMap.put(ProcessNodeTmpModel.PROCESS_TMP_ID, id);
        processNodeTmpMapper.deleteByMap(processNodeTmpMap);
        // 删除流程扩展信息
        Map<String, Object> processTmpExtMap = new HashMap<>();
        processTmpExtMap.put(ProcessTmpExtModel.PROCESS_TMP_ID, id);
        processTmpExtMapper.deleteByMap(processTmpExtMap);
        // 删除流程信息
        processTmpMapper.deleteById(id);

    }

    @Override
    @Transactional
    public void add(ProcessTmpReqVo reqVo) {
        checkAddOrUpdate(reqVo);
        //reqVo.setAllNodeInfo(getTestJson());
        log.debug("add ProcessTmp param:{}", JSONObject.toJSONString(reqVo));
        Long currentUserAccountId = jwtUtils.getCurrentUserAccountId();
        // 新增流程信息
        ProcessTmpModel processTmpModel = new ProcessTmpModel();
        BeanUtils.copyProperties(reqVo, processTmpModel);
        processTmpModel.setCreateBy(currentUserAccountId);
        processTmpModel.setCreateTime(new Date());
        processTmpMapper.insert(processTmpModel);
        // 新增流程扩展信息
        ProcessTmpExtModel processTmpExtModel = new ProcessTmpExtModel();
        processTmpExtModel.setProcessTmpId(processTmpModel.getId());
        processTmpExtModel.setAllNodeInfo(reqVo.getAllNodeInfo());
        processTmpExtMapper.insert(processTmpExtModel);

        if (!ObjectUtils.isEmpty(reqVo.getAllNodeInfo())) {
            //添加流程节点信息
            processNodeTmpService.add(processTmpModel.getId(), reqVo.getAllNodeInfo());
        }

    }

    @Override
    @Transactional
    public void update(ProcessTmpReqVo reqVo) {
        checkAddOrUpdate(reqVo);
        log.debug("update ProcessTmp param:{}", JSONObject.toJSONString(reqVo.getAllNodeInfo()));
        Long currentUserAccountId = jwtUtils.getCurrentUserAccountId();
        // 修改流程信息
        ProcessTmpModel processTmpModel = new ProcessTmpModel();
        BeanUtils.copyProperties(reqVo, processTmpModel);
        processTmpModel.setUpdateBy(currentUserAccountId);
        processTmpModel.setUpdateTime(new Date());
        processTmpMapper.updateById(processTmpModel);

        // 修改流程扩展信息
        UpdateWrapper<ProcessTmpExtModel> updateWrapper = new UpdateWrapper<>();
        updateWrapper.eq(ProcessTmpExtModel.PROCESS_TMP_ID, processTmpModel.getId());
        ProcessTmpExtModel processTmpExtModel = new ProcessTmpExtModel();
        processTmpExtModel.setProcessTmpId(processTmpModel.getId());
        processTmpExtModel.setAllNodeInfo(reqVo.getAllNodeInfo());
        processTmpExtMapper.update(processTmpExtModel, updateWrapper);

        if (!ObjectUtils.isEmpty(reqVo.getAllNodeInfo())) {
            // 删除流程节点信息
            Map<String, Object> deleteNode = new HashMap<>();
            deleteNode.put(ProcessNodeTmpModel.PROCESS_TMP_ID, processTmpModel.getId());
            processNodeTmpMapper.deleteByMap(deleteNode);

            // 删除节点参数信息
            Map<String, Object> deleteNodeParam = new HashMap<>();
            deleteNodeParam.put(ProcessNodeParamTmpModel.PROCESS_TMP_ID, processTmpModel.getId());
            processNodeParamTmpMapper.deleteByMap(deleteNodeParam);

            //添加流程节点信息
            processNodeTmpService.add(processTmpModel.getId(), reqVo.getAllNodeInfo());
        }
    }

    @Override
    public String coverProcessTmpExt(String allNodeInfo) {
        Map<Long, EquipmentRespVo> equipmentRespVoAllMap = equipmentService.getEquipmentRespVoAllMap();
        JSONArray jsonArray = JSONObject.parseArray(allNodeInfo);
        for (int i = 0; i < jsonArray.size(); i++) {
            JSONObject jsonObject = JSONObject.parseObject(JSONObject.toJSONString(jsonArray.get(i)));
            String id = jsonObject.getString("id");
            Object customData = jsonObject.get("data");
            String customDataStr = JSONObject.toJSONString(customData);
            JSONObject customDataJsonObj = JSONObject.parseObject(customDataStr);
            String resourceType = customDataJsonObj.getString("resourceType");
            // 设备节点信息
            if (resourceType.equals("equipmentNode")) {
                Long equipmentId = customDataJsonObj.getLong("equipmentId");
                EquipmentRespVo equipmentRespVo = equipmentRespVoAllMap.get(equipmentId);
                String image = equipmentRespVo.getImage();
                customDataJsonObj.put("imageUrl", image);
                jsonObject.put("data", customDataJsonObj);
                jsonArray.set(i, jsonObject);
            }
        }
        return JSONObject.toJSONString(jsonArray);
    }

    private void checkAddOrUpdate(ProcessTmpReqVo reqVo) {
        QueryWrapper<ProcessTmpModel> queryWrapper = new QueryWrapper<>();
        if (reqVo.getId() != null) {
            queryWrapper.ne(ProcessTmpModel.ID, reqVo.getId());
        }
        queryWrapper.eq(ProcessTmpModel.NAME, reqVo.getName());
        Long count = processTmpMapper.selectCount(queryWrapper);
        if (count > 0) {
            throw new BusinessException("流程模板名称已经存在");
        }
    }

    private String getTestJson() {
        String strTest = "[\n" +
                "    {\n" +
                "        \"shape\": \"edge\",\n" +
                "        \"attrs\": {\n" +
                "            \"line\": {\n" +
                "                \"stroke\": \"#A2B1C3\",\n" +
                "                \"targetMarker\": {\n" +
                "                    \"name\": \"block\",\n" +
                "                    \"width\": 12,\n" +
                "                    \"height\": 8\n" +
                "                }\n" +
                "            }\n" +
                "        },\n" +
                "        \"id\": \"57240c21-5839-48b0-8c13-91019b4703b0\",\n" +
                "        \"zIndex\": 0,\n" +
                "        \"source\": {\n" +
                "            \"cell\": \"d3d6681a-4748-4cdc-ad80-275f2f8bd74c\",\n" +
                "            \"port\": \"e95c9751-9bb1-4fec-a357-a115ec92bb91\"\n" +
                "        },\n" +
                "        \"target\": {\n" +
                "            \"cell\": \"8c59f3db-7aad-4dfe-95f7-94ad5ed83884\",\n" +
                "            \"port\": \"a5f40a09-33e3-48f6-9f51-a1173acecde5\"\n" +
                "        }\n" +
                "    },\n" +
                "    {\n" +
                "        \"shape\": \"edge\",\n" +
                "        \"attrs\": {\n" +
                "            \"line\": {\n" +
                "                \"stroke\": \"#A2B1C3\",\n" +
                "                \"targetMarker\": {\n" +
                "                    \"name\": \"block\",\n" +
                "                    \"width\": 12,\n" +
                "                    \"height\": 8\n" +
                "                }\n" +
                "            }\n" +
                "        },\n" +
                "        \"id\": \"813b9477-4049-4e7b-a9c5-5ebe389f1516\",\n" +
                "        \"zIndex\": 0,\n" +
                "        \"source\": {\n" +
                "            \"cell\": \"d3d6681a-4748-4cdc-ad80-275f2f8bd74c\",\n" +
                "            \"port\": \"67625a28-0420-4008-8faa-9d97b5bb674e\"\n" +
                "        },\n" +
                "        \"target\": {\n" +
                "            \"cell\": \"ad49a091-597e-4858-8c83-e8a7418a3ae6\",\n" +
                "            \"port\": \"a5f40a09-33e3-48f6-9f51-a1173acecde5\"\n" +
                "        }\n" +
                "    },\n" +
                "    {\n" +
                "        \"shape\": \"edge\",\n" +
                "        \"attrs\": {\n" +
                "            \"line\": {\n" +
                "                \"stroke\": \"#A2B1C3\",\n" +
                "                \"targetMarker\": {\n" +
                "                    \"name\": \"block\",\n" +
                "                    \"width\": 12,\n" +
                "                    \"height\": 8\n" +
                "                }\n" +
                "            }\n" +
                "        },\n" +
                "        \"id\": \"c4ccb4c3-98f4-4f47-b3de-7c0939260bd0\",\n" +
                "        \"zIndex\": 0,\n" +
                "        \"source\": {\n" +
                "            \"cell\": \"8c59f3db-7aad-4dfe-95f7-94ad5ed83884\",\n" +
                "            \"port\": \"eadfcdd0-8010-40f0-9c2d-9c04f649646a\"\n" +
                "        },\n" +
                "        \"target\": {\n" +
                "            \"cell\": \"c0e1654f-0463-4093-9582-5ef4584b269e\",\n" +
                "            \"port\": \"08f5f315-9228-4073-8bb2-b14c4d3cff7b\"\n" +
                "        }\n" +
                "    },\n" +
                "    {\n" +
                "        \"shape\": \"edge\",\n" +
                "        \"attrs\": {\n" +
                "            \"line\": {\n" +
                "                \"stroke\": \"#A2B1C3\",\n" +
                "                \"targetMarker\": {\n" +
                "                    \"name\": \"block\",\n" +
                "                    \"width\": 12,\n" +
                "                    \"height\": 8\n" +
                "                }\n" +
                "            }\n" +
                "        },\n" +
                "        \"id\": \"e2598556-3dda-476a-9c5e-d5f4b3ec7526\",\n" +
                "        \"zIndex\": 0,\n" +
                "        \"source\": {\n" +
                "            \"cell\": \"ad49a091-597e-4858-8c83-e8a7418a3ae6\",\n" +
                "            \"port\": \"eadfcdd0-8010-40f0-9c2d-9c04f649646a\"\n" +
                "        },\n" +
                "        \"target\": {\n" +
                "            \"cell\": \"c0e1654f-0463-4093-9582-5ef4584b269e\",\n" +
                "            \"port\": \"7281049f-64de-44b6-8d71-e79340cf0295\"\n" +
                "        }\n" +
                "    },\n" +
                "    {\n" +
                "        \"position\": {\n" +
                "            \"x\": 80,\n" +
                "            \"y\": 180\n" +
                "        },\n" +
                "        \"size\": {\n" +
                "            \"width\": 66,\n" +
                "            \"height\": 36\n" +
                "        },\n" +
                "        \"attrs\": {\n" +
                "            \"text\": {\n" +
                "                \"text\": \"开始\"\n" +
                "            },\n" +
                "            \"body\": {\n" +
                "                \"rx\": 20,\n" +
                "                \"ry\": 26\n" +
                "            }\n" +
                "        },\n" +
                "        \"visible\": true,\n" +
                "        \"shape\": \"equipment\",\n" +
                "        \"ports\": {\n" +
                "            \"groups\": {\n" +
                "                \"top\": {\n" +
                "                    \"position\": \"top\",\n" +
                "                    \"attrs\": {\n" +
                "                        \"circle\": {\n" +
                "                            \"r\": 4,\n" +
                "                            \"magnet\": true,\n" +
                "                            \"stroke\": \"#5F95FF\",\n" +
                "                            \"strokeWidth\": 1,\n" +
                "                            \"fill\": \"#fff\",\n" +
                "                            \"style\": {\n" +
                "                                \"visibility\": \"hidden\"\n" +
                "                            }\n" +
                "                        }\n" +
                "                    }\n" +
                "                },\n" +
                "                \"right\": {\n" +
                "                    \"position\": \"right\",\n" +
                "                    \"attrs\": {\n" +
                "                        \"circle\": {\n" +
                "                            \"r\": 4,\n" +
                "                            \"magnet\": true,\n" +
                "                            \"stroke\": \"#5F95FF\",\n" +
                "                            \"strokeWidth\": 1,\n" +
                "                            \"fill\": \"#fff\",\n" +
                "                            \"style\": {\n" +
                "                                \"visibility\": \"hidden\"\n" +
                "                            }\n" +
                "                        }\n" +
                "                    }\n" +
                "                },\n" +
                "                \"bottom\": {\n" +
                "                    \"position\": \"bottom\",\n" +
                "                    \"attrs\": {\n" +
                "                        \"circle\": {\n" +
                "                            \"r\": 4,\n" +
                "                            \"magnet\": true,\n" +
                "                            \"stroke\": \"#5F95FF\",\n" +
                "                            \"strokeWidth\": 1,\n" +
                "                            \"fill\": \"#fff\",\n" +
                "                            \"style\": {\n" +
                "                                \"visibility\": \"hidden\"\n" +
                "                            }\n" +
                "                        }\n" +
                "                    }\n" +
                "                },\n" +
                "                \"left\": {\n" +
                "                    \"position\": \"left\",\n" +
                "                    \"attrs\": {\n" +
                "                        \"circle\": {\n" +
                "                            \"r\": 4,\n" +
                "                            \"magnet\": true,\n" +
                "                            \"stroke\": \"#5F95FF\",\n" +
                "                            \"strokeWidth\": 1,\n" +
                "                            \"fill\": \"#fff\",\n" +
                "                            \"style\": {\n" +
                "                                \"visibility\": \"hidden\"\n" +
                "                            }\n" +
                "                        }\n" +
                "                    }\n" +
                "                }\n" +
                "            },\n" +
                "            \"items\": [\n" +
                "                {\n" +
                "                    \"group\": \"top\",\n" +
                "                    \"id\": \"3fbb6d0a-14c5-4457-a8dd-d5e7e923b834\"\n" +
                "                },\n" +
                "                {\n" +
                "                    \"group\": \"right\",\n" +
                "                    \"id\": \"e95c9751-9bb1-4fec-a357-a115ec92bb91\"\n" +
                "                },\n" +
                "                {\n" +
                "                    \"group\": \"bottom\",\n" +
                "                    \"id\": \"67625a28-0420-4008-8faa-9d97b5bb674e\"\n" +
                "                },\n" +
                "                {\n" +
                "                    \"group\": \"left\",\n" +
                "                    \"id\": \"46542eba-5e8b-4390-a637-48608be50b5e\"\n" +
                "                }\n" +
                "            ]\n" +
                "        },\n" +
                "        \"id\": \"d3d6681a-4748-4cdc-ad80-275f2f8bd74c\",\n" +
                "        \"customParams\": {" +
                "           \"equipmentMethodTmpId\":2,\n" +
                "            \"equipmentParams\": [{\"name\":\"test\", \"value\":\"777\", \"useType\":0,\"variableFlag\":1,\"paramType\":\"string\"}],\n" +
                "        },\n" +
                "        \"zIndex\": 1\n" +
                "    },\n" +
                "    {\n" +
                "        \"position\": {\n" +
                "            \"x\": 250,\n" +
                "            \"y\": 130\n" +
                "        },\n" +
                "        \"size\": {\n" +
                "            \"width\": 66,\n" +
                "            \"height\": 36\n" +
                "        },\n" +
                "        \"attrs\": {\n" +
                "            \"text\": {\n" +
                "                \"text\": \"过程\"\n" +
                "            }\n" +
                "        },\n" +
                "        \"visible\": true,\n" +
                "        \"shape\": \"custom-rect\",\n" +
                "        \"ports\": {\n" +
                "            \"groups\": {\n" +
                "                \"top\": {\n" +
                "                    \"position\": \"top\",\n" +
                "                    \"attrs\": {\n" +
                "                        \"circle\": {\n" +
                "                            \"r\": 4,\n" +
                "                            \"magnet\": true,\n" +
                "                            \"stroke\": \"#5F95FF\",\n" +
                "                            \"strokeWidth\": 1,\n" +
                "                            \"fill\": \"#fff\",\n" +
                "                            \"style\": {\n" +
                "                                \"visibility\": \"hidden\"\n" +
                "                            }\n" +
                "                        }\n" +
                "                    }\n" +
                "                },\n" +
                "                \"right\": {\n" +
                "                    \"position\": \"right\",\n" +
                "                    \"attrs\": {\n" +
                "                        \"circle\": {\n" +
                "                            \"r\": 4,\n" +
                "                            \"magnet\": true,\n" +
                "                            \"stroke\": \"#5F95FF\",\n" +
                "                            \"strokeWidth\": 1,\n" +
                "                            \"fill\": \"#fff\",\n" +
                "                            \"style\": {\n" +
                "                                \"visibility\": \"hidden\"\n" +
                "                            }\n" +
                "                        }\n" +
                "                    }\n" +
                "                },\n" +
                "                \"bottom\": {\n" +
                "                    \"position\": \"bottom\",\n" +
                "                    \"attrs\": {\n" +
                "                        \"circle\": {\n" +
                "                            \"r\": 4,\n" +
                "                            \"magnet\": true,\n" +
                "                            \"stroke\": \"#5F95FF\",\n" +
                "                            \"strokeWidth\": 1,\n" +
                "                            \"fill\": \"#fff\",\n" +
                "                            \"style\": {\n" +
                "                                \"visibility\": \"hidden\"\n" +
                "                            }\n" +
                "                        }\n" +
                "                    }\n" +
                "                },\n" +
                "                \"left\": {\n" +
                "                    \"position\": \"left\",\n" +
                "                    \"attrs\": {\n" +
                "                        \"circle\": {\n" +
                "                            \"r\": 4,\n" +
                "                            \"magnet\": true,\n" +
                "                            \"stroke\": \"#5F95FF\",\n" +
                "                            \"strokeWidth\": 1,\n" +
                "                            \"fill\": \"#fff\",\n" +
                "                            \"style\": {\n" +
                "                                \"visibility\": \"hidden\"\n" +
                "                            }\n" +
                "                        }\n" +
                "                    }\n" +
                "                }\n" +
                "            },\n" +
                "            \"items\": [\n" +
                "                {\n" +
                "                    \"group\": \"top\",\n" +
                "                    \"id\": \"c47ca454-4bde-40f6-aa2c-c5f232287daa\"\n" +
                "                },\n" +
                "                {\n" +
                "                    \"group\": \"right\",\n" +
                "                    \"id\": \"eadfcdd0-8010-40f0-9c2d-9c04f649646a\"\n" +
                "                },\n" +
                "                {\n" +
                "                    \"group\": \"bottom\",\n" +
                "                    \"id\": \"b2402a79-c749-424a-ba7b-ac4a0e38791e\"\n" +
                "                },\n" +
                "                {\n" +
                "                    \"group\": \"left\",\n" +
                "                    \"id\": \"a5f40a09-33e3-48f6-9f51-a1173acecde5\"\n" +
                "                }\n" +
                "            ]\n" +
                "        },\n" +
                "        \"id\": \"8c59f3db-7aad-4dfe-95f7-94ad5ed83884\",\n" +
                "        \"customParams\": {\n" +
                "            \"test\": \"开始节点\",\n" +
                "            \"number\": \"1\"\n" +
                "        },\n" +
                "        \"zIndex\": 2\n" +
                "    },\n" +
                "    {\n" +
                "        \"position\": {\n" +
                "            \"x\": 210,\n" +
                "            \"y\": 250\n" +
                "        },\n" +
                "        \"size\": {\n" +
                "            \"width\": 66,\n" +
                "            \"height\": 36\n" +
                "        },\n" +
                "        \"attrs\": {\n" +
                "            \"text\": {\n" +
                "                \"text\": \"parallelNode\"\n" +
                "            }\n" +
                "        },\n" +
                "        \"visible\": true,\n" +
                "        \"shape\": \"custom-rect\",\n" +
                "        \"ports\": {\n" +
                "            \"groups\": {\n" +
                "                \"top\": {\n" +
                "                    \"position\": \"top\",\n" +
                "                    \"attrs\": {\n" +
                "                        \"circle\": {\n" +
                "                            \"r\": 4,\n" +
                "                            \"magnet\": true,\n" +
                "                            \"stroke\": \"#5F95FF\",\n" +
                "                            \"strokeWidth\": 1,\n" +
                "                            \"fill\": \"#fff\",\n" +
                "                            \"style\": {\n" +
                "                                \"visibility\": \"hidden\"\n" +
                "                            }\n" +
                "                        }\n" +
                "                    }\n" +
                "                },\n" +
                "                \"right\": {\n" +
                "                    \"position\": \"right\",\n" +
                "                    \"attrs\": {\n" +
                "                        \"circle\": {\n" +
                "                            \"r\": 4,\n" +
                "                            \"magnet\": true,\n" +
                "                            \"stroke\": \"#5F95FF\",\n" +
                "                            \"strokeWidth\": 1,\n" +
                "                            \"fill\": \"#fff\",\n" +
                "                            \"style\": {\n" +
                "                                \"visibility\": \"hidden\"\n" +
                "                            }\n" +
                "                        }\n" +
                "                    }\n" +
                "                },\n" +
                "                \"bottom\": {\n" +
                "                    \"position\": \"bottom\",\n" +
                "                    \"attrs\": {\n" +
                "                        \"circle\": {\n" +
                "                            \"r\": 4,\n" +
                "                            \"magnet\": true,\n" +
                "                            \"stroke\": \"#5F95FF\",\n" +
                "                            \"strokeWidth\": 1,\n" +
                "                            \"fill\": \"#fff\",\n" +
                "                            \"style\": {\n" +
                "                                \"visibility\": \"hidden\"\n" +
                "                            }\n" +
                "                        }\n" +
                "                    }\n" +
                "                },\n" +
                "                \"left\": {\n" +
                "                    \"position\": \"left\",\n" +
                "                    \"attrs\": {\n" +
                "                        \"circle\": {\n" +
                "                            \"r\": 4,\n" +
                "                            \"magnet\": true,\n" +
                "                            \"stroke\": \"#5F95FF\",\n" +
                "                            \"strokeWidth\": 1,\n" +
                "                            \"fill\": \"#fff\",\n" +
                "                            \"style\": {\n" +
                "                                \"visibility\": \"hidden\"\n" +
                "                            }\n" +
                "                        }\n" +
                "                    }\n" +
                "                }\n" +
                "            },\n" +
                "            \"items\": [\n" +
                "                {\n" +
                "                    \"group\": \"top\",\n" +
                "                    \"id\": \"c47ca454-4bde-40f6-aa2c-c5f232287daa\"\n" +
                "                },\n" +
                "                {\n" +
                "                    \"group\": \"right\",\n" +
                "                    \"id\": \"eadfcdd0-8010-40f0-9c2d-9c04f649646a\"\n" +
                "                },\n" +
                "                {\n" +
                "                    \"group\": \"bottom\",\n" +
                "                    \"id\": \"b2402a79-c749-424a-ba7b-ac4a0e38791e\"\n" +
                "                },\n" +
                "                {\n" +
                "                    \"group\": \"left\",\n" +
                "                    \"id\": \"a5f40a09-33e3-48f6-9f51-a1173acecde5\"\n" +
                "                }\n" +
                "            ]\n" +
                "        },\n" +
                "        \"id\": \"ad49a091-597e-4858-8c83-e8a7418a3ae6\",\n" +
                "        \"customParams\": {\n" +
                "            \"nodeFlag\": \"start\",\n" +
                "            \"parallelStartNodeId\": \"001\"\n" +
                "        },\n" +
                "        \"zIndex\": 3\n" +
                "    },\n" +
                "    {\n" +
                "        \"position\": {\n" +
                "            \"x\": 390,\n" +
                "            \"y\": 190\n" +
                "        },\n" +
                "        \"size\": {\n" +
                "            \"width\": 66,\n" +
                "            \"height\": 36\n" +
                "        },\n" +
                "        \"attrs\": {\n" +
                "            \"text\": {\n" +
                "                \"text\": \"结束\"\n" +
                "            },\n" +
                "            \"body\": {\n" +
                "                \"rx\": 20,\n" +
                "                \"ry\": 26\n" +
                "            }\n" +
                "        },\n" +
                "        \"visible\": true,\n" +
                "        \"shape\": \"custom-rect\",\n" +
                "        \"ports\": {\n" +
                "            \"groups\": {\n" +
                "                \"top\": {\n" +
                "                    \"position\": \"top\",\n" +
                "                    \"attrs\": {\n" +
                "                        \"circle\": {\n" +
                "                            \"r\": 4,\n" +
                "                            \"magnet\": true,\n" +
                "                            \"stroke\": \"#5F95FF\",\n" +
                "                            \"strokeWidth\": 1,\n" +
                "                            \"fill\": \"#fff\",\n" +
                "                            \"style\": {\n" +
                "                                \"visibility\": \"hidden\"\n" +
                "                            }\n" +
                "                        }\n" +
                "                    }\n" +
                "                },\n" +
                "                \"right\": {\n" +
                "                    \"position\": \"right\",\n" +
                "                    \"attrs\": {\n" +
                "                        \"circle\": {\n" +
                "                            \"r\": 4,\n" +
                "                            \"magnet\": true,\n" +
                "                            \"stroke\": \"#5F95FF\",\n" +
                "                            \"strokeWidth\": 1,\n" +
                "                            \"fill\": \"#fff\",\n" +
                "                            \"style\": {\n" +
                "                                \"visibility\": \"hidden\"\n" +
                "                            }\n" +
                "                        }\n" +
                "                    }\n" +
                "                },\n" +
                "                \"bottom\": {\n" +
                "                    \"position\": \"bottom\",\n" +
                "                    \"attrs\": {\n" +
                "                        \"circle\": {\n" +
                "                            \"r\": 4,\n" +
                "                            \"magnet\": true,\n" +
                "                            \"stroke\": \"#5F95FF\",\n" +
                "                            \"strokeWidth\": 1,\n" +
                "                            \"fill\": \"#fff\",\n" +
                "                            \"style\": {\n" +
                "                                \"visibility\": \"hidden\"\n" +
                "                            }\n" +
                "                        }\n" +
                "                    }\n" +
                "                },\n" +
                "                \"left\": {\n" +
                "                    \"position\": \"left\",\n" +
                "                    \"attrs\": {\n" +
                "                        \"circle\": {\n" +
                "                            \"r\": 4,\n" +
                "                            \"magnet\": true,\n" +
                "                            \"stroke\": \"#5F95FF\",\n" +
                "                            \"strokeWidth\": 1,\n" +
                "                            \"fill\": \"#fff\",\n" +
                "                            \"style\": {\n" +
                "                                \"visibility\": \"hidden\"\n" +
                "                            }\n" +
                "                        }\n" +
                "                    }\n" +
                "                }\n" +
                "            },\n" +
                "            \"items\": [\n" +
                "                {\n" +
                "                    \"group\": \"top\",\n" +
                "                    \"id\": \"08f5f315-9228-4073-8bb2-b14c4d3cff7b\"\n" +
                "                },\n" +
                "                {\n" +
                "                    \"group\": \"right\",\n" +
                "                    \"id\": \"9dfb6125-e40d-4a9a-a5e1-2489bd060422\"\n" +
                "                },\n" +
                "                {\n" +
                "                    \"group\": \"bottom\",\n" +
                "                    \"id\": \"7281049f-64de-44b6-8d71-e79340cf0295\"\n" +
                "                },\n" +
                "                {\n" +
                "                    \"group\": \"left\",\n" +
                "                    \"id\": \"d6e564e8-9ea6-46ef-9284-def27cd719f0\"\n" +
                "                }\n" +
                "            ]\n" +
                "        },\n" +
                "        \"id\": \"c0e1654f-0463-4093-9582-5ef4584b269e\",\n" +
                "        \"customParams\": {\n" +
                "            \"test\": \"开始节点\",\n" +
                "            \"number\": \"1\"\n" +
                "        },\n" +
                "        \"zIndex\": 4\n" +
                "    }\n" +
                "]";
        return strTest;
    }

}
